import sys
import os
import time

from config import args


def log_path(project_path):
    return os.path.join(project_path, 'logging', time.strftime('%m%d-%H%M%S') + '.log')


sys_path = sys.path[0]
if args.train_device == 'PC':
    sys_path = r'F:\FlyAI\BaldClassification_FlyAI'
DATA_PATH = os.path.join(sys_path, 'data', 'input', 'BaldClassification')

MODEL_PATH = os.path.join(sys_path, 'data', 'output', 'model')
MODEL_FILE_PATH11 = os.path.join(MODEL_PATH, 'model1_ens.pt')
MODEL_FILE_PATH12 = os.path.join(MODEL_PATH, 'model1_sep.pt')  # separate best
MODEL_FILE_PATH13 = os.path.join(MODEL_PATH, 'model1_ens_test.pt')
MODEL_FILE_PATH14 = os.path.join(MODEL_PATH, 'model1_sep_test.pt')  # separate best
MODEL_FILE_PATH21 = os.path.join(MODEL_PATH, 'model2_ens.pt')
MODEL_FILE_PATH22 = os.path.join(MODEL_PATH, 'model2_sep.pt')  # separate best
MODEL_FILE_PATH23 = os.path.join(MODEL_PATH, 'model2_ens_test.pt')
MODEL_FILE_PATH24 = os.path.join(MODEL_PATH, 'model2_sep_test.pt')  # separate best
MODEL_FILE_PATH31 = os.path.join(MODEL_PATH, 'model3_ens.pt')
MODEL_FILE_PATH32 = os.path.join(MODEL_PATH, 'model3_sep.pt')  # separate best
MODEL_FILE_PATH33 = os.path.join(MODEL_PATH, 'model3_ens_test.pt')
MODEL_FILE_PATH34 = os.path.join(MODEL_PATH, 'model3_sep_test.pt')  # separate best

LOG_PATH = os.path.join(sys_path, 'log_tensorboard')
LOGGING_FILE = log_path(sys_path)
MEAN_PATH = os.path.join(sys_path, 'mean.npy')
STD_PATH = os.path.join(sys_path, 'std.npy')

if args.train_device == 'flyai':
    PRETRAINED_MODEL_PATH = 'https://www.flyai.com/m/'
elif args.train_device == '1024gpu':
    PRETRAINED_MODEL_PATH = '/root/'  # 1024gpu
    # PRETRAINED_MODEL_PATH = '/data/nextcloud/dbc2017/files/'  # 1024gpu
    # PRETRAINED_MODEL_PATH = sys_path  # colab
elif args.train_device == 'PC':
    PRETRAINED_MODEL_PATH = r'C:\Users\zichu\Desktop/'  # PC

if args.pretrain:
    pretrain_name = {'resnet50': 'resnet50-19c8e357.pth',
                     'efficientnetb4': 'adv-efficientnet-b4-44fb3a87.pth',
                     'efficientnetb3': 'adv-efficientnet-b3-cdd7c0f4.pth'}
    if args.pretrain_bald:
        pretrain_name.update({
            'resnest50': 'densenet121_bald.pt',
            'densenet121': 'resnest50_bald.pt'
        })
    else:
        pretrain_name.update({
            'resnest50': 'resnest50-fb9de5b3.pth',
            'densenet121': 'densenet121-a639ec97.pth'
        })

    resnest50_path = os.path.join(PRETRAINED_MODEL_PATH, pretrain_name['resnest50'])
    densenet121_path = os.path.join(PRETRAINED_MODEL_PATH, pretrain_name['densenet121'])
    resnet50_path = os.path.join(PRETRAINED_MODEL_PATH, pretrain_name['resnet50'])
    efficientnetb4_path = os.path.join(PRETRAINED_MODEL_PATH, pretrain_name['efficientnetb4'])
    efficientnetb3_path = os.path.join(PRETRAINED_MODEL_PATH, pretrain_name['efficientnetb3'])

resnet50_url = 'https://download.pytorch.org/models/resnet50-19c8e357.pth'
densenet121_url = 'https://download.pytorch.org/models/densenet121-a639ec97.pth'
efficientnetb4_url = 'https://github.com/lukemelas/EfficientNet-PyTorch/releases/download/' \
                     '1.0/adv-efficientnet-b4-44fb3a87.pth'


if __name__ == '__main__':
    name = 'efficientnetb4'
    filename = os.path.basename(name)
    print(filename)
    print(eval(f'{name}_url'))